# -*-coding:utf-8-*-

'''
1.定义一个字典，来存储遍历一次后不符合条件的键值，存储为key为值，value为索引
2.目标值 - 首次遍历的值得到的【值】在 字典里遍历key
3.存在：返回字典内key对应的索引值和for循环当前值的索引
4.不存在：将当前值和索引，以key和value存储进字典

'''

def twoSum(nums, target):
    dic = {}
    for index,num in enumerate(nums):
        another_num = target - num
        if another_num in dic:
            return [dic[another_num],index]
        dic[num] = index
    return None


print(twoSum([1, 2, 3, 4, 5], 9))